#ifndef BANK_DATAMANAGER_HH
#define BANK_DATAMANAGER_HH

#include <string>
#include <vector>
#include <memory>
#include "Customer.hh"
#include "Account.hh"
#include "Transaction.hh"

// 可选的数据管理类，用于数据的持久化（从文件读写客户和账户信息）
class DataManager {
public:
    DataManager(const std::string& dataDir = "data/");

    // 保存数据到文件
    bool saveCustomers(const std::vector<std::shared_ptr<Customer>>& customers) const;
    bool saveAccounts(const std::vector<std::shared_ptr<Account>>& accounts) const;
    bool saveTransactions(const std::vector<Transaction>& transactions) const;
    
    // 从文件加载数据
    std::vector<std::shared_ptr<Customer>> loadCustomers() const;
    std::vector<std::shared_ptr<Account>> loadAccounts(const std::vector<std::shared_ptr<Customer>>& customers) const;
    std::vector<Transaction> loadTransactions() const;
    
    // 保存和加载所有数据
    bool saveAllData(const std::vector<std::shared_ptr<Customer>>& customers,
                    const std::vector<std::shared_ptr<Account>>& accounts,
                    const std::vector<Transaction>& transactions) const;
    
    bool loadAllData(std::vector<std::shared_ptr<Customer>>& customers,
                    std::vector<std::shared_ptr<Account>>& accounts,
                    std::vector<Transaction>& transactions) const;

private:
    std::string dataDirectory;
    
    // 文件路径
    std::string customersFilePath;
    std::string accountsFilePath;
    std::string transactionsFilePath;
    
    // 确保数据目录存在
    bool ensureDataDirectoryExists() const;
};

#endif // BANK_DATAMANAGER_HH 